<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>帖子详情_win</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
	<style>
	.aui-nav {
		height: 42px;
	}
	.aui-nav .aui-bar-tab {
		height: 42px;
		background-color: #EDEDED;
		position: relative;
	}
	.aui-nav .aui-bar-tab:after {
		border-top: 1px solid #c8c7cc;
		display: block;
		content: '';
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		-webkit-transform-origin: 0 0;
		-webkit-transform: scale(1);
		pointer-events: none;
	}
	@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
		.aui-nav .aui-bar-tab:after {
		right: -100%;
		bottom: -100%;
		-webkit-transform: scale(0.5);
		}
	}
	.aui-nav .aui-bar-tab li {
		color: #656766;
	}
	.aui-nav .aui-bar-tab .aui-iconfont {
		font-size: 22px;
		color: #8f8f94;
		padding-top: 5px;
		height: 30px;
		line-height: 30px;
		display: inline-block;
	}
	
	.commentCount{
		position: absolute;
		top: 0.2rem;
		left: 50%;
		background-color: #2FA746;
		border-radius: 0px;
		font-size: 10px;
		padding: 3px 4px;
		display: none;
	}
	</style>

</head>
<body>
    <header class="aui-bar aui-bar-nav aui-bar-primary" id="aui-header">
	    <a class="aui-pull-left" tapmode onclick="api.closeWin()">
	        <span class="aui-iconfont aui-icon-left"></span>返回
	    </a>
        <div class="aui-title">帖子详情</div>
        <a class="aui-iconfont aui-icon-menu aui-pull-right"></a>
    </header>
    <footer class="aui-nav" id="aui-footer">
        <ul class="aui-bar-tab">
            <li id="comment"  tapmode style="position: relative;">
                <span class="aui-iconfont aui-icon-comment"></span>
                <span class="aui-badge aui-badge-danger commentCount" id="commentCount">0</span>
            </li>
            <!--li id="tabbar2" tapmode onclick="">
                <span class="aui-iconfont aui-icon-edit"></span>
            </li-->
            <li id="favor" >
                <span id="icon-favor" class="aui-iconfont aui-icon-favor"></span>
            </li>
            <li id="tabbar4" onclick="">
                <span class="aui-iconfont aui-icon-share"></span>
            </li>
            <li id="report">
                <span class="aui-iconfont aui-icon-warn"></span>
            </li>
        </ul>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/OSChinaApi.js" ></script>
<script type="text/javascript" src="../script/common.js" ></script>
<script type="text/javascript">
	var pageParam;
    apiready = function(){
    	pageParam = api.pageParam;
        var header = $api.byId('aui-header');
        $api.fixStatusBar(header); 
        var headerPos = $api.offset(header);
        var footerPos = $api.offset($api.byId('aui-footer'));
        var body_h = $api.offset($api.dom('body')).h;
        api.openFrame({
            name: 'post_detail_frm',
            url: 'post_detail_frm.html',
            bounces: true,
            pageParam: pageParam,
            rect: {
                x: 0,
                y: headerPos.h,
                w: 'auto',
                h: body_h - headerPos.h - footerPos.h
            }
        });
        
        
        
        
    };
    
	/*
	 * 收藏
	 * @param  type  1: 收藏   0: 取消收藏
	 */
    function favorite( type , objid){
    	if( type ){
    		favorite_add(objid, 2, $api.getStorage('user_uid'));
    	}else{
    		favorite_delete(objid, 2, $api.getStorage('user_uid'));
    	}
    }
    

	// 通过post_detail_frm设置post_detail_win的举报按钮
	function set_report_button( id, url ){
		var report = $api.byId('report');
		$api.attr(report, 'onclick', 'community_report( '+id+', \''+url+'\')');
	}
	
	// 举报
	function community_report( id, url ){
		api.prompt({
			title: '举报',
			msg: '链接地址：' + url,
		    buttons:['确定', '取消']
		},function(ret,err){
		    if(ret.buttonIndex == 1){
				api.ajax({
				    url: OpenAPI.community_report,
				    method: 'post',
				    timeout: 30,
				    dataType: 'text',
				    returnAll: true,
				    data:{
				        values: {
				        	memo: ret.text,
				        	obj_id: id,
				        	obj_type: 2,
				        	reason: 4,
				        	url: url,
				        },
				    }
				},function(ret,err){
				    if (ret) {
				    	var msg = '';
				        if(parseInt(ret.statusCode) == 200){
							msg = '举报成功';
				        }else{
				        	msg = '举报失败';
				        }
						api.toast({
						    msg: msg,
						    duration:2000,
						    location: 'middle'
						});
				    }else {
				        log('错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode);
				    	showAjaxErrMsg(err.code);
				    }
				});
		    }
		});
	}
</script>
</html>